package com.chang.jason.recyclerviewinrecyclerview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chang.jason.recyclerviewinrecyclerview.adapter.CountSectionAdapter;
import com.chang.jason.recyclerviewinrecyclerview.viewholders.SectionedSpanSizeLookup;
//import com.truizlop.sectionedrecyclerview.SectionedSpanSizeLookup;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private RecyclerView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        recyclerView = (RecyclerView) findViewById(R.id.recycle_veiw);

        CountSectionAdapter adapter = new CountSectionAdapter(this);
        recyclerView.setAdapter(adapter);
        GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
        SectionedSpanSizeLookup lookup = new SectionedSpanSizeLookup(adapter, layoutManager);
        layoutManager.setSpanSizeLookup(lookup);
        recyclerView.setLayoutManager(layoutManager);
//        adapter=new MainRvAdapter(this,getData());
//        recyclerView.setAdapter(adapter);

    }

    /**
     * 测试数据
     * @return
     */
    private List<List<String>> getData(){
        List<List<String>> list=new ArrayList<>();
        for(int i=0;i<5;i++){
            List<String> ls=new ArrayList<>();
            for(int j=0;i<i;j++){
                ls.add("name"+i+j);
            }
            list.add(ls);
        }
        return list;
    }
}
